﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestESBProxy.Messages;
using PServiceBus.MessageProxy.Interface;
using PServiceBus.MessageProxy;
using PServiceBus.Transports;

namespace ChatServer {

    public class ChatServiceServer : IESBMessage<ChatRequest, ChatResponse>  {

        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "2222")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        public ChatResponse Handle(ChatRequest msg) {
            Console.WriteLine("Received Chat Request with ID = {0}", msg.ESBCorrelationID);
            var response = new ChatResponse() {
                UserName = String.Format("{0}Server", msg.UserName),
                Message = "Server: Hello Client"
            };
            return response;
        }

    }

    class Program {
        static void Main(string[] args) {

            ProxyService.Start();

            Console.WriteLine("Waiting for request..... Press enter to close");
            Console.ReadLine();

            ProxyService.Shutdown();
        }
    }
}
